//set echarts data

import count from "../api/count";
import option from "./option";

export function countCollegeAdmit(collegeName,province) {
    count.countCollegeAdmit(collegeName,province).then(function (response) {
        //set echarts data
        option.collegeAdmitScienceLine.xAxis.data = []
        option.collegeAdmitScienceLine.series[0].data = []
        option.collegeAdmitScienceLine.series[1].data = []
        option.collegeAdmitLiberalLine.xAxis.data = []
        option.collegeAdmitLiberalLine.series[0].data = []
        option.collegeAdmitLiberalLine.series[1].data = []
        const collegeAdmitList = response.data.data;
        for (let i = 0; i < collegeAdmitList.length ; i++){
            if (collegeAdmitList[i].admitBatch === '本科批' || collegeAdmitList[i].admitBatch === '本科一批' ||
                collegeAdmitList[i].admitBatch === '本科批A段' || collegeAdmitList[i].admitBatch === '本科一批A段' ||
                collegeAdmitList[i].admitBatch === '本科A批'){
                if (collegeAdmitList[i].examType === '理科'){
                    option.collegeAdmitScienceLine.xAxis.data.push(collegeAdmitList[i].year)
                    option.collegeAdmitScienceLine.series[0].data.push(collegeAdmitList[i].lowestScore)
                    option.collegeAdmitScienceLine.series[1].data.push(collegeAdmitList[i].lowestRank)
                }
                if (collegeAdmitList[i].examType === '文科'){
                    option.collegeAdmitLiberalLine.xAxis.data.push(collegeAdmitList[i].year)
                    option.collegeAdmitLiberalLine.series[0].data.push(collegeAdmitList[i].lowestScore)
                    option.collegeAdmitLiberalLine.series[1].data.push(collegeAdmitList[i].lowestRank)
                }
            }
        }
    })
}

export default {countCollegeAdmit}